package ru.scan2d.main.impl;

import java.awt.Event;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

import ru.scan2d.main.MainWindowPresenter;
import ru.scan2d.main.system.ClientFactory;

public class MainMenuBar extends JMenuBar{

	public MainMenuBar(ClientFactory clientFactory, final MainWindowPresenter.Listener listener){
		
		super();
		JMenu menuFile = new JMenu("File");
		JMenuItem itemFileOpen = new JMenuItem("Open");
		itemFileOpen.setAccelerator(KeyStroke.getKeyStroke(79, Event.CTRL_MASK));
		JMenuItem itemFileSave = new JMenuItem("Save");
		itemFileSave.setAccelerator(KeyStroke.getKeyStroke(83, Event.CTRL_MASK));
		JMenuItem itemFileClear = new JMenuItem("Clear");

		itemFileSave.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				listener.onSave();
			}
		});
		
		itemFileOpen.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				listener.onOpen();
			}
		});
		
		itemFileClear.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				listener.onClear();
			}
		});

		menuFile.add(itemFileOpen);
		menuFile.add(itemFileSave);
		//menuFile.add(itemFileClear);
		this.add(menuFile);
		JMenu viewFile = new JMenu("View");
		JMenu helpFile = new JMenu("Help");
		this.add(viewFile);
		this.add(helpFile);
	}
	
}
